package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.util.ArrayList;

public class dtMainActivity extends AppCompatActivity {

    private Button but1,but2,but3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dt_main);

        but1 = (Button)findViewById(R.id.but1);
        but2 = (Button)findViewById(R.id.but2);
        but3 = (Button)findViewById(R.id.but3);
//        Bundle bundle = getIntent().getExtras();
//        ArrayList<username> userArrayList = (ArrayList<username>) bundle.getSerializable("key");
        but1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(dtMainActivity.this,zcMainActivity.class);
                startActivityForResult(intent,1);
            }
        });
        but2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = getIntent().getExtras();
                if(bundle==null){
                    Toast.makeText(dtMainActivity.this, "还没有账户", Toast.LENGTH_SHORT).show();
                    return;
                }
//                bundle.putParcelableArrayList("List1",list);
                else {
                    ArrayList<username> userArrayList = (ArrayList<username>) bundle.getSerializable("key");
                    Bundle bundle1 = new Bundle();
                    bundle1.putSerializable("key", userArrayList);
                    Intent intent = new Intent(dtMainActivity.this, drMainActivity.class);
                    intent.putExtras(bundle);
                    startActivityForResult(intent, 1);
                }
            }
        });
        but3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(intent.ACTION_MAIN);
                intent.addCategory(intent.CATEGORY_HOME);
                startActivity(intent);
            }
        });

    }
}